package com.situ.ymall.controller.api;

import com.situ.ymall.entity.APIResult;
import com.situ.ymall.entity.User;
import com.situ.ymall.service.OrderService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpSession;
import java.util.List;

@RestController
@RequestMapping("/api/order")
public class APIOrderController {
    @Autowired
    private OrderService orderService;
    //获取所有
    @PostMapping("/getList")
    public List getList(HttpSession session){
        User user = (User) session.getAttribute("user");

        List orders = orderService.getByUserId(user.getId());

        return orders;
    }
}
